package com.thirteenClassicsServer.mapper;

import com.thirteenClassics.annotation.AutoFill;
import com.thirteenClassics.entity.SentenceLink;
import com.thirteenClassics.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SentenceLinkMapper {


    @AutoFill(value = OperationType.INSERT)
    void insert(SentenceLink sentenceLink);

    @Delete("delete from sentence_link where sentence_id=#{sentenceId} and minority_book_id=#{bookId}")
    void delete(Long sentenceId, Long bookId);

    List<SentenceLink> selectjd(Long sentencejd, Long id);

    @Select("select sentencejdb_id from sentence_link where sentence_id=#{sentenceId} and "
            + "minority_book_id=#{id}")
    List<Long> selectSentenceId(Long sentenceId, Long id);

    @AutoFill(value = OperationType.INSERT)
//    @Insert({
//            "<script>",
//            "INSERT INTO sentence_link (sentence_id, sentencejdb_id, sentence_ids, book_name, minority_book_id) VALUES ",
//            "<foreach collection='list' item='item' separator=','>",
//            "(#{item.sentenceId}, #{item.sentencejdbId}, #{item.sentenceIds}, #{item.bookName}, #{item.bookId})",
//            "</foreach>",
//            "</script>"
//    })
    void insertBatch(List<SentenceLink> sentenceLinkList);
}
